const path = require('path');
const AppendStringPlugin = require('./plugins/AppendStringPlugin.js'); 
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
  entry: './src/main.ts', // 入口文件
  output: {
    filename: 'main.js', // 输出文件名
    path: path.resolve(__dirname, ''), // 输出路径
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  devtool: "source-map",  
  mode: 'development', // 模式（'development' 或 'production'）  
  plugins: [
    //plugins/AppendStringPlugin
    new AppendStringPlugin({
      filename: 'main.js', // 要修改的文件名
      stringToAppend: `      
      Object.defineProperty(exports, "__esModule", { value: true });
      exports.onPublish = onPublish;
      exports.onDestroy = onDestroy;`, // 要添加的字符串
    })
  ],
};